package com.cloudm.technician.data.network

import com.cloudm.technician.data.model.Response
import com.cloudm.technician.data.model.UploadTokenInfo
import com.cloudm.technician.data.model.User
import com.cloudm.technician.data.model.VersionInfo
import io.reactivex.Observable
import retrofit2.http.*

/**
 * 作者: wesley
 * 时间: 2017/11/20
 * 描述: 通用模块的接口----闪屏页、登录页、注册页, 获取上传凭证
 */
interface CommonApi {

    /**
     * 获取验证码
     * mobile: 手机号
     * status: 1: 注册 2：找回密码
     */
    @FormUrlEncoded
    @POST("azb/json/member/getActiveCode")
    fun getVerificationCode(@Field("mobile") mobile: String, @Field(
            "status") status: Int): Observable<Response<String?>>


    /**
     * 注册
     * mobile：手机号
     * activeCode: 验证码
     * password: 密码
     */
    @FormUrlEncoded
    @POST("azb/json/member/memberRegister")
    fun register(@Field("mobile") mobile: String, @Field(
            "activeCode") verificationCode: String, @Field(
            "password") password: String): Observable<Response<User?>>


    /**
     * 找回密码
     * mobile：手机号
     * activeCode: 验证码
     * password: 密码
     */
    @FormUrlEncoded
    @POST("azb/json/member/forgetPassword")
    fun findPassword(@Field("mobile") mobile: String, @Field(
            "activeCode") verificationCode: String, @Field(
            "password") password: String): Observable<Response<User?>>


    /**
     * 登录
     * mobile: 手机号
     * password: 密码
     */
    @FormUrlEncoded
    @POST("azb/json/member/memberLogin")
    fun login(@Field("mobile") mobile: String, @Field(
            "password") verificationCode: String): Observable<Response<User?>>


    /**
     * 获取上传凭证
     */
    @GET("n/api_qn/uptoken")
    fun getUploadInfo(): Observable<Response<UploadTokenInfo?>>


    /**
     * 检查版本更新
     */
    @GET("azb/json/version/getVersion")
    fun checkVersion(@Query("version") version: String, @Query(
            "system") system: String = "Android"): Observable<Response<VersionInfo?>>
}